import {mapGetters, mapState} from 'vuex'
export default {
  data () {
    return {
      
    }
  },
  computed: {
    ...mapGetters('cart', ['total', 'checkedCount'])
  },
  onShow() {
    this.setBarBadge()
  },
  watch: {
    total(val) {
      this.setBarBadge()
    },
  },
  methods: {
    //为 tabBar 某一项的右上角添加文本。
    setBarBadge () {
      uni.setTabBarBadge({
        index: 2,
        //text值必须为字符串
        text: this.total + ''
      })
    },
  }
}